package cn.hanyx.vlog.order.controller;


import cn.hanyx.vlog.api.dto.ResponseObject;
import cn.hanyx.vlog.api.vo.Order;
import cn.hanyx.vlog.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author hanyx
 * @since 2021-11-27
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @GetMapping("/{orderId}")
    public ResponseObject<Order> get(@PathVariable Integer orderId) {
        return new ResponseObject(orderService.getById(orderId));
    }

    @GetMapping
    public ResponseObject<Order> list() {
        return new ResponseObject(orderService.list());
    }

    @PostMapping
    public ResponseObject save(@RequestBody Order order) {
        return new ResponseObject(orderService.save(order));
    }

    @PutMapping
    public ResponseObject update(@RequestBody Order order) {
        orderService.updateById(order);
        return new ResponseObject(orderService.updateById(order));
    }

}

